package com.example.demo.dao;

import com.example.demo.model.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

@Mapper
public interface UserMapper {


    @Select("select * from users")
    @Results(id = "userMap",value = {
            @Result(column = "user_id",property = "userid"),
            @Result(column = "username",property = "username"),
            @Result(column ="role_id",property = "role"
                    ,one=@One(select ="com.example.demo.dao.RoleMapper.selectById",fetchType = FetchType.LAZY))
    })
    public List<User> select();


    @Select("select * from users")
    @ResultMap(value = "userMap")
    public  List<User> select2();
}
